package org.edu.modules.kwgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.edu.modules.kwgl.entity.VeJwQkJiankao;
import org.edu.modules.kwgl.mapper.VeJwQkJiankaoMapper;
import org.edu.modules.kwgl.service.IVeJwQkJiankaoService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 清考监考
 * @Author: jeecg-boot
 * @Date:   2021-05-08
 * @Version: V1.0
 */
@Service
public class VeJwQkJiankaoServiceImpl extends ServiceImpl<VeJwQkJiankaoMapper, VeJwQkJiankao> implements IVeJwQkJiankaoService {

    @Override
    public List<String> get2teacheridByQkid(int qkid) {
        VeJwQkJiankao jiankao = baseMapper.selectOne(new QueryWrapper<VeJwQkJiankao>()
                .eq("qkid", qkid)
                .eq("type", 1).last(" limit 1 ").orderByDesc("id"));

        VeJwQkJiankao xunkao = baseMapper.selectOne(new QueryWrapper<VeJwQkJiankao>()
                .eq("qkid", qkid)
                .eq("type", 2).last(" limit 1 ").orderByDesc("id"));

        List<String> list = new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao.getTeacherid().toString());
        }else{
            list.add("暂未安排");
        }
        if(xunkao!=null){
            list.add(xunkao.getTeacherid().toString());
        }else {
            list.add("暂未安排");
        }

        return list;
    }

    @Override
    public List<VeJwQkJiankao> get2teacherByQkid(int qkid) {
        VeJwQkJiankao jiankao = baseMapper.selectOne(new QueryWrapper<VeJwQkJiankao>()
                .eq("qkid", qkid)
                .eq("type", 1).last(" limit 1 ").orderByDesc("id"));

        VeJwQkJiankao xunkao = baseMapper.selectOne(new QueryWrapper<VeJwQkJiankao>()
                .eq("qkid", qkid)
                .eq("type", 2).last(" limit 1 ").orderByDesc("id"));

        List<VeJwQkJiankao> list = new ArrayList<>();
        if(jiankao!=null){
            list.add(jiankao);
        }else{
            list.add(null);
        }
        if(xunkao!=null){
            list.add(xunkao);
        }else {
            list.add(null);
        }

        return list;
    }
}
